home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_08
/
9n08101a
< prev
next >
Wrap
Text File
|
1991-06-04
|
827b
|
29 lines
char *word_breaks = " \n\t";
int slow_wordcount(char *str)
{
int count = 0;
char *s;
s=str;
s+=strspn(s,word_breaks); //Skip leading white space
while(s)
{
s=strpbrk(s,word_breaks); //Find the beginning of the white space
if(s) s+=strspn(s,word_breaks); //Find the end of the white space
count++; //Increment count - Note it starts as 0 not 1
}
return(count);
}
void slow_str_to_ptrarray(char *orgstr, char *ptrarray[])
{
int i=0;
char *s;
s=strtok(orgstr,word_breaks); //Find the first word
while(*s)
{
ptrarray[i]=s; //assign it
i++;
s=strtok(NULL,word_breaks); //Find the rest of the words
}
}